package mapper;

import entity.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface SysUserMapper {

    // 新增人员
    @Insert("INSERT INTO sys_user (username, password, role, create_time) " +
            "VALUES (#{username}, #{password}, #{role}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id") // 开启自增主键回写，将生成的ID赋值给实体类的id属性
    int insertSysUser(SysUser sysUser);

    // 修改人员信息

    int updateSysUser(SysUser sysUser);

    // 删除指定人员
    @Delete("DELETE FROM sys_user WHERE id = #{id}")
    int deleteSysUserById(Long id);

    // 查询所有人员信息
    @Select("SELECT * FROM sys_user")
    List<SysUser> selectAllSysUsers();

    // 根据用户ID查询人员信息
    @Select("SELECT * FROM sys_user WHERE id = #{id}")
    SysUser selectSysUserById(Long id);

    // 根据用户名查询人员信息
    @Select("SELECT * FROM sys_user WHERE username = #{username}")
    SysUser selectSysUserByUsername(String username);
}